﻿@{var currentApplication = Session["SELECTED-APPLICATION"] as SecurityApi.Model.Application; }

<h3>APPLICATION ROLES</h3>

@(Html.Kendo().Grid<SecurityApi.DataAccess.Role>()
    .Name("Grid")
    .HtmlAttributes(new { style = "height:500px;" }) 
    .Columns(columns => {
        
        //If your grid is ajax bound. You should also define a ClientTemplate for all template columns:
        columns.Template(@<text>
                    @Html.ActionLink("Remove", "SelectUser", "User", new { userId = @item.RoleId})  
                    </text>)
                    .ClientTemplate("<a href='" + Url.Content("~/Role/RemoveRole/?") + "roleId= #= RoleId #'" + ">Remove</a>") //always use Url.Content to get the correct relative path
                    .Title("Remove").Width(100);

        columns.Bound(c => c.RoleId).Width(100);
                    
        columns.Bound(c => c.RoleName);
                        

    })
    .Pageable()
    .Sortable()
    .Selectable()
    .Resizable(resize => resize.Columns(true))
    .Reorderable(reorder => reorder.Columns(true))
    .Filterable()
    .Scrollable()
    .DataSource(dataSource => dataSource
        .Ajax()
        .PageSize(50)
        .Model(model => model.Id(p => p.RoleId))
        .Read(read => read.Action("AjaxGetApplicationRoles", "Role", new {applicationId=@currentApplication.ApplicationId}))
    )
)
